prompt="Why do you like programming ? Input your reason."
prompt+="If you don't want to input,please input 0"
#设置循环因子
active=1

file_name='D:\\GITEE\\study_code\\Python\\2022-11-12\\reasons.txt'
with open(file_name,'a') as file_object:
    while active:
        reason=input(prompt)
        #判断是否写入文件
        if reason !='0':
            file_object.write(f"{reason}\n")
        #改变循环因子，从而退出循环
        else:
            active=0
            print("Input Termination")

